<?php

	header("Content-Type: text/html;charset=utf-8");

	include("../_judge.php");

	include("../../function/function.php");

	

	$action = chkstr(trim($_REQUEST['action']));

	$now_time = date("Y-m-d H:i:s");

	$re_url = trim($_REQUEST['re_url']);

	$newsid = $_REQUEST['newsid'];

	$news_option = chkstr(trim($_REQUEST['news_option']));


	if(is_array($newsid)){ // 拆分数组

		$newsid = implode(',',$newsid);

	}

	

	if($action == "del"){

		if($news_option == "del"){

			if(!empty($newsid)){

				// 删除数据

				$mysql = new sqlstr("kboy_user"); 

				$news_sql = $mysql -> deleteSql("uid in($newsid)");

				$news_res = mysql_query($news_sql);

				if($news_res){

					echo ok("操作成功",$_SERVER['HTTP_REFERER']);

				}else{

					echo erro("服务器内部错误");

				}

			}else{

				echo erro("至少选择一条记录进行操作");

			}

		}elseif($news_option == "isheader"){

			if(!empty($newsid)){

				// 修改

				$mysql = new sqlstr("kboy_user"); 

				$mysql -> set("user_leader",1,true);

				$news_sql = $mysql -> updateSql("uid in($newsid)");

				$news_res = mysql_query($news_sql);

				if($news_res){

					echo ok("操作成功",$_SERVER['HTTP_REFERER']);

				}else{

					echo erro("服务器内部错误");

				}

			}else{

				echo erro("至少选择一条记录进行操作");

			}

		}elseif($news_option == "noheader"){

			if(!empty($newsid)){

				// 修改

				$mysql = new sqlstr("kboy_user"); 

				$mysql -> set("user_leader",0,true);

				$news_sql = $mysql -> updateSql("uid in($newsid)");

				$news_res = mysql_query($news_sql);

				if($news_res){

					echo ok("操作成功",$_SERVER['HTTP_REFERER']);

				}else{

					echo erro("服务器内部错误");

				}

			}else{

				echo erro("至少选择一条记录进行操作");

			}

		}elseif($news_option == "cvaheader"){

			if(!empty($newsid)){

				// 修改
				$newsids = explode(',', $newsid);
				$mysql = new sqlstr("kboy_user"); 

				foreach ($newsids as $k => $v) {
					$shijian = date("YmdHis").'_'.$v;
					mysql_query("update kboy_user set user_trade_no = '$shijian' where uid = '$v'");
				}
				$mysql -> set("user_style",1,true);
				$news_sql = $mysql -> updateSql("uid in($newsid)");

				$news_res = mysql_query($news_sql);

				if($news_res){

					echo ok("操作成功",$_SERVER['HTTP_REFERER']);

				}else{

					echo erro("服务器内部错误");

				}

			}else{

				echo erro("至少选择一条记录进行操作");

			}

		}elseif($news_option == "nocva"){

			if(!empty($newsid)){

				// 修改
				$newsids = explode(',', $newsid);
				$mysql = new sqlstr("kboy_user"); 

				foreach ($newsids as $k => $v) {
					mysql_query("update kboy_user set user_trade_no = '' where uid = '$v'");
				}
				$mysql -> set("user_style",0,true);
				$news_sql = $mysql -> updateSql("uid in($newsid)");

				$news_res = mysql_query($news_sql);

				if($news_res){

					echo ok("操作成功",$_SERVER['HTTP_REFERER']);

				}else{

					echo erro("服务器内部错误");

				}

			}else{

				echo erro("至少选择一条记录进行操作");

			}

		}elseif($news_option == "istui"){

			if(!empty($newsid)){

				// 修改

				$mysql = new sqlstr("kboy_user"); 

				$mysql -> set("user_tui",1,true);

				$news_sql = $mysql -> updateSql("uid in($newsid)");

				$news_res = mysql_query($news_sql);

				if($news_res){

					echo ok("操作成功",$_SERVER['HTTP_REFERER']);

				}else{

					echo erro("服务器内部错误");

				}

			}else{

				echo erro("至少选择一条记录进行操作");

			}


		}elseif($news_option == "notui"){

			if(!empty($newsid)){

				// 修改

				$mysql = new sqlstr("kboy_user"); 

				$mysql -> set("user_tui",0,true);

				$news_sql = $mysql -> updateSql("uid in($newsid)");

				$news_res = mysql_query($news_sql);

				if($news_res){

					echo ok("操作成功",$_SERVER['HTTP_REFERER']);

				}else{

					echo erro("服务器内部错误");

				}

			}else{

				echo erro("至少选择一条记录进行操作");

			}

			

			

		}elseif($news_option == "ishei"){

			if(!empty($newsid)){

				// 修改

				$mysql = new sqlstr("kboy_user"); 

				$mysql -> set("user_hei",1,true);

				$news_sql = $mysql -> updateSql("uid in($newsid)");

				$news_res = mysql_query($news_sql);

				if($news_res){

					echo ok("操作成功",$_SERVER['HTTP_REFERER']);

				}else{

					echo erro("服务器内部错误");

				}

			}else{

				echo erro("至少选择一条记录进行操作");

			}

			

			

		}else{

			erro("请选择要操作的方式");

		}

	}elseif($action == "resetpwd"){
		$update_sql = "update kboy_user set user_password='".md5(md5("123456"))."' where uid=$id";
		mysql_query($update_sql);
		echo ok("密码重置为123456","newsmanage.php");
	}else{

		echo erro("参数错误");

	}

	

?>

